import {getTopic,getTopicDetail,getTopicRelated,getTopicLeave} from '../../api';

export function topicAction(){
    return async(dispatch:Function)=>{
        const result = await getTopic();

        dispatch({
            type:'INIT_TOPIC',
            payload:result.data.data
        })
    }
}
export function topicDetail(id:number){
    return async(dispatch:Function)=>{
        const result = await getTopicDetail(id);
        dispatch({
            type:'INIT_DETAIL',
            payload:result.data
        })
    } 
}
export function topicRelated(id:number){
    return async(dispatch:Function)=>{
        const result = await getTopicRelated(id);
        dispatch({
            type:'INIT_RELATEDS',
            payload:result.data
        })
    } 
}
export function topicLeave(valueId:string,typeId?:string,page?:string,size?:string){
    return async(dispatch:Function)=>{
        const result = await getTopicLeave(valueId,typeId,page,size);
        dispatch({
            type:'INIT_LEAVE',
            payload:result.data
        })
    } 
}